package com.zhangxu.microservice.employee.web.controller.feign;


import com.zhangxu.microservice.common.result.CommonResult;
import com.zhangxu.microservice.employee.api.response.EmployeeAuthDTO;
import com.zhangxu.microservice.employee.biz.service.EmployeeBizService;
import com.zhangxu.microservice.employee.domain.dto.EmployeeDTO;
import com.zhangxu.microservice.employee.web.mapstruct.EmployeeConverter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/feign/auth/employee/")
@Tag(name = "用户管理(feign)")
@RequiredArgsConstructor
public class EmployeeAuthController {

    private final EmployeeBizService employeeBizService;
    private final EmployeeConverter employeeConverter;

    /**
     * 根据用户名查询用户信息（内部 Feign 调用）
     */
    @GetMapping("search/account")
    public CommonResult<EmployeeAuthDTO> get(@RequestParam("account") String account) {
        EmployeeDTO employeeDTO = employeeBizService.getByAccount(account);
        EmployeeAuthDTO employeeAuthDTO = employeeConverter.toEmployeeAuthDTO(employeeDTO);
        return CommonResult.success(employeeAuthDTO);
    }
}
